package com.seventh.parkingrent.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.seventh.parkingrent.commens.Result;
import com.seventh.parkingrent.controller.form.UserAuditForm;
import com.seventh.parkingrent.domain.User;
import com.seventh.parkingrent.service.IUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.BindingResult;
import org.springframework.validation.FieldError;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 用户表 前端控制器
 * </p>
 *
 * @author Lucas
 * @since 2021-08-25
 */
@RestController
@Slf4j
@CrossOrigin("*")
public class UserController {
    @Resource
    private IUserService userService;



    @GetMapping("/getNeedAuditUser")
    public Result getNeedAuditUser(@RequestParam(name = "pageIndex",defaultValue = "1") Integer pageIndex,
                                   @RequestParam(name="pageSize",defaultValue = "3") Integer pageSize){
        log.info("前端发起获取待审核用户请求");

        IPage<User> pages = userService.getNeedAuditUser(pageIndex,pageSize);

        return Result.success(pages);
    }

    //获取需要审核的用户数量
    @GetMapping("/getNeedAuditUserNo")
    public Result getNeedAuditUserNo(){
        log.info("前台提请需审核的用户数量");

        Integer needAuditUserNo=userService.getNeedAuditUserNo();
        return Result.success(needAuditUserNo);
    }

    //获取用户名
    @GetMapping("/getUsername")
    public Result getUsername(){
        log.info("前端提请所有用户的名字");

        List<String> usernames = userService.selectUsername();

        return Result.success(usernames);
    }
}

